package c.f.d.a.a.a.b;

import android.text.TextUtils;
import c.f.a.a.a.a;
import com.huawei.hms.aaid.constant.AaidIdConstant;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public final class b {
    public static final String a = "b";
    public static final String[] b = new String[]{AaidIdConstant.SIGNATURE_SHA256, "SHA-384", "SHA-512"};

    public static String a(String str) {
        String str2 = "";
        if (!TextUtils.isEmpty(str)) {
            String str3 = AaidIdConstant.SIGNATURE_SHA256;
            if (!TextUtils.isEmpty(str3)) {
                Object obj = null;
                for (String equals : b) {
                    if (equals.equals(str3)) {
                        obj = 1;
                        break;
                    }
                }
                if (obj == null) {
                    a.m(a, "algorithm is not safe or legal");
                    return str2;
                }
                try {
                    MessageDigest instance = MessageDigest.getInstance(str3);
                    instance.update(str.getBytes("UTF-8"));
                    str2 = a.e(instance.digest());
                    return str2;
                } catch (UnsupportedEncodingException unused) {
                    a.m(a, "Error in generate SHA UnsupportedEncodingException");
                    return str2;
                } catch (NoSuchAlgorithmException unused2) {
                    a.m(a, "Error in generate SHA NoSuchAlgorithmException");
                    return str2;
                }
            }
        }
        a.m(a, "content or algorithm is null.");
        return str2;
    }
}
